testgtk: Connect to draw signal in alpha test
authorBenjamin Otte <otte@redhat.com>
Wed, 8 Sep 2010 20:25:50 +0000 (22:25 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 26 Sep 2010 13:11:41 +0000 (15:11 +0200)
Test still behaves weird, no idea why though.

tests/testgtk.c

index 025f89d467870fae89ec460756913e86a92df05a..d94ca811df681f1828b7377f3827d95dffee5194 100644 (file)
@@ -127,24 +127,20 @@ build_option_menu (gchar           *items[],
 
 
 static gboolean
-on_alpha_window_expose (GtkWidget      *widget,
-                       GdkEventExpose *expose)
+on_alpha_window_draw (GtkWidget *widget,
+                      cairo_t   *cr)
 {
-  GtkAllocation allocation;
-  cairo_t *cr;
   cairo_pattern_t *pattern;
-  int radius;
-
-  cr = gdk_cairo_create (gtk_widget_get_window (widget));
+  int radius, width, height;
 
-  gtk_widget_get_allocation (widget, &allocation);
-
-  radius = MIN (allocation.width, allocation.height) / 2;
-  pattern = cairo_pattern_create_radial (allocation.width / 2,
-                                         allocation.height / 2,
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
+  radius = MIN (width, height) / 2;
+  pattern = cairo_pattern_create_radial (width / 2,
+                                         height / 2,
                                         0.0,
-                                         allocation.width / 2,
-                                         allocation.height / 2,
+                                         width / 2,
+                                         height / 2,
                                         radius * 1.33);
 
   if (gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)) &&
@@ -167,8 +163,6 @@ on_alpha_window_expose (GtkWidget      *widget,
   cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
   cairo_paint (cr);
 
-  cairo_destroy (cr);
-
   return FALSE;
 }
 
@@ -299,8 +293,8 @@ create_alpha_window (GtkWidget *widget)
                                            NULL);
 
       gtk_widget_set_app_paintable (window, TRUE);
-      g_signal_connect (window, "expose-event",
-                       G_CALLBACK (on_alpha_window_expose), NULL);
+      g_signal_connect (window, "draw",
+                       G_CALLBACK (on_alpha_window_draw), NULL);
 
       content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));